<?php

/**
 * @Author: king
 * @Date:   2019-05-11 22:15:47
 * @Last Modified by:   king
 * @Last Modified time: 2019-06-01 13:07:49
 */

namespace App\Models\Api;

use App\Exceptions\ApiException;
use App\Models\Api\Base;

class LanmeiCounselorAnswerComment extends Base
{
    protected $table = 'counselor_answer_comment';

    /**
     * 评论标签信息
     * @return Model\relation\HasMany
     */
    public function comments()
    {
        return $this->hasMany('LanmeiCommentTag', 'cac_id');
    }

     /**
     * 创建默认评价
     * @param $defaultData
     * @throws \Exception
     */
  public function createDefault($defaultData, $informComment)
    {

        if ($defaultData)
        {
            $this->create($defaultData);
        }

        if ($informComment)
        {
            $this->whereIn('ca_id', $informComment)->update(['grade' => 1]);
        }
    }

}
